#ifndef _TEXTURE_MANAGER_H
#define _TEXTURE_MANAGER_H

#include <map>
#include <vector>
#include <string>

#include "SFML\Graphics.hpp"
#include "ResourceLoadTypes.h"


class TextureManager
{
public:
	typedef sf::Texture* (TextureManager::*LoadTexFptr)(const std::string& filepath, const std::string& id, bool remove);

	static TextureManager* getSingletonPtr();
	static void cleanSingleton();

	sf::Texture* loadTexture(const std::string& filepath, const std::string& id, bool remove = false);

	sf::Texture* getTexture(const std::string& id);
	sf::Texture* getTexture(sf::Texture* texture);
	void unloadTexture(const std::string& id);
	void unloadAllTextures();
	void flush();		// deletes textures saved in _removeList

	void setMode(int);

private:
	TextureManager(void);
	~TextureManager(void);

	inline sf::Texture* loadTextureFromArchive(const std::string& filepath, const std::string& id, bool remove = false);
	inline sf::Texture* loadTextureFromFile(const std::string& filepath, const std::string& id, bool remove = false);

	sf::Texture* doesTextureExist(const std::string id);

	static TextureManager* _instance;
	
	std::vector<std::string> _removeList;
	std::map<std::string, sf::Texture*> _textures;
	int _mode;	// defines from where textures are loaded, archived or from filepaths
	LoadTexFptr _loadTexFptr[RESOURCE_SIZE];
};

#endif // _TEXTURE_MANAGER_H

